home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Telnet Server 1.0 / MacSocket.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-14  |  6.1 KB  |  164 lines  |  [TEXT/KAHL]

  1. /* Socket headers for MacSocket calls*/
  2.  
  3. #pragma once
  4.  
  5. struct    hostent    {
  6.         char    *h_name;        /*official name of host*/
  7.         char    **h_aliases;    /*alias list*/
  8.         long        h_addrtype;        /*host address type*/
  9.         long        h_length;        /*length of address*/
  10.         char    **h_addr_list;    /*list of addresses from nameserver*/
  11. #define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
  12. };
  13.  
  14. struct  servent {
  15.         char    *s_name;        /* official service name */
  16.         char    **s_aliases;    /* alias list */
  17.         long     s_port;         /* port # */
  18.         char    *s_proto;       /* protocol to use */
  19. };
  20.  
  21.  
  22.  
  23. typedef unsigned    short    u_short;
  24. typedef    unsigned    long        u_int;
  25. typedef    unsigned    long    u_long;
  26. typedef    unsigned    char    u_char;
  27. typedef long    fd_mask;
  28.  
  29. struct in_addr {
  30.         u_long s_addr;
  31. };
  32.  
  33. struct    sockaddr {
  34.         u_short    sa_family;        /*address family*/
  35.         char    sa_data[14];        /*up to 14 bytes of direct address*/
  36. };
  37.  
  38. struct sockaddr_in {
  39.         short   sin_family;
  40.         u_short sin_port;
  41.         struct  in_addr sin_addr;
  42.         char    sin_zero[8];
  43. };
  44.  
  45. struct timeval {
  46.         long    tv_sec;         /* seconds */
  47.         long    tv_usec;        /* and microseconds */
  48. };
  49.  
  50.  
  51. #define NBBY            8L
  52. #define NFDBITS (sizeof(fd_mask) * NBBY)
  53. #define howmany(x, y)   (((x)+((y)-1L))/(y))
  54. #define CHANNELSIZE     16L      /* Size of a channel */
  55. #define FD_SETSIZE      512L
  56.  
  57. typedef struct fd_set {
  58.         fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  59. } fd_set;
  60.  
  61. #define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
  62. #define FD_SET(n, p)    ((p)->fds_bits[(n)/CHANNELSIZE/NFDBITS] |= (1L << (((n)/CHANNELSIZE) % NFDBITS)))
  63. #define    AF_INET            0L
  64. #define    SOCK_STREAM        0L
  65. #define    NUM_SOCKETS        32L
  66. #define BUFF_SIZE        8192L
  67.  
  68.  
  69.  
  70. long                connect (long s, struct sockaddr *name, long namelen);
  71. struct hostent    *gethostbyname (char *name);
  72. struct servent    *getservbyname(char *name, char *proto);
  73. long                recv (long s, char *buf, long len, long flags);
  74. long                send (long s, char *msg, long len, long flags);
  75. long                socket (long af, long type, long protocol);
  76. long                shutdown (long s, long how);
  77. long                socket_close (long s);
  78. void                bzero(void *s, long size);
  79. unsigned    short    htons(unsigned    short    hostshort);
  80. int                    s_select( long nfds, long *readfds, long *writefds, 
  81.                             long *exceptfds, struct timeval *timeout);
  82.  
  83. /*
  84.  * Error codes
  85.  */
  86.  
  87. #define EPERM           1               /* Not owner */
  88. #define ENXIO           6               /* No such device or address */
  89. #define E2BIG           7               /* Arg list too long */
  90. #define ENOEXEC         8               /* Exec format error */
  91. #define ECHILD          10              /* No children */
  92. #define EAGAIN          11              /* No more processes */
  93. #define ENOMEM          12              /* Not enough core */
  94. #define EFAULT          14              /* Bad address */
  95. #define ENOTBLK         15              /* Block device required */
  96. #define EXDEV           18              /* Cross-device link */
  97. #define EISDIR          21              /* Is a directory */
  98. #define ENOTTY          25              /* Not a typewriter */
  99. #define ETXTBSY         26              /* Text file busy */
  100. #define EFBIG           27              /* File too large */
  101. #define ESPIPE          29              /* Illegal seek */
  102. #define EMLINK          31              /* Too many links */
  103. #define EPIPE           32              /* Broken pipe */
  104.  
  105. /* math software */
  106.  
  107. /* non-blocking and interrupt i/o */
  108. #define EWOULDBLOCK     35              /* Operation would block */
  109. #define EDEADLK         EWOULDBLOCK     /* ditto */
  110. #define EINPROGRESS     36              /* Operation now in progress */
  111. #define EALREADY        37              /* Operation already in progress */
  112.  
  113. /* ipc/network software */
  114.  
  115.         /* argument errors */
  116. #define ENOTSOCK        38              /* Socket operation on non-socket */
  117. #define EDESTADDRREQ    39              /* Destination address required */
  118. #define EMSGSIZE        40              /* Message too long */
  119. #define EPROTOTYPE      41              /* Protocol wrong type for socket */
  120. #define ENOPROTOOPT     42              /* Protocol not available */
  121. #define EPROTONOSUPPORT 43              /* Protocol not supported */
  122. #define ESOCKTNOSUPPORT 44              /* Socket type not supported */
  123. #define EOPNOTSUPP      45              /* Operation not supported on socket */
  124. #define EPFNOSUPPORT    46              /* Protocol family not supported */
  125. #define EAFNOSUPPORT    47              /* Address family not supported by proto
  126. col family */
  127. #define EADDRINUSE      48              /* Address already in use */
  128. #define EADDRNOTAVAIL   49              /* Can't assign requested address */
  129.  
  130.         /* operational errors */
  131. #define ENETDOWN        50              /* Network is down */
  132. #define ENETUNREACH     51              /* Network is unreachable */
  133. #define ENETRESET       52              /* Network dropped connection on reset *
  134. /
  135. #define ECONNABORTED    53              /* Software caused connection abort */
  136. #define ECONNRESET      54              /* Connection reset by peer */
  137. #define ENOBUFS         55              /* No buffer space available */
  138. #define EISCONN         56              /* Socket is already connected */
  139. #define ENOTCONN        57              /* Socket is not connected */
  140. #define ESHUTDOWN       58              /* Can't send after socket shutdown */
  141. #define ETOOMANYREFS    59              /* Too many references: can't splice */
  142. #define ETIMEDOUT       60              /* Connection timed out */
  143. #define ECONNREFUSED    61              /* Connection refused */
  144.  
  145.         /* */
  146. #define ELOOP           62              /* Too many levels of symbolic links */
  147. #define ENAMETOOLONG    63              /* File name too long */
  148.  
  149. /* should be rearranged */
  150. #define EHOSTDOWN       64              /* Host is down */
  151. #define EHOSTUNREACH    65              /* No route to host */
  152. #define ENOTEMPTY       66              /* Directory not empty */
  153.  
  154. /* quotas & mush */
  155. #define EPROCLIM        67              /* Too many processes */
  156. #define EUSERS          68              /* Too many users */
  157. #define EDQUOT          69              /* Disc quota exceeded */
  158.  
  159. #define EVMSERR 65535           /* VMS-specific error code for non-translatable
  160. errors from VMS to C */
  161.  
  162.  
  163.  
  164.